package com.meichis.yndms.vm;

import android.app.Application;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.meichis.mcsappframework.utils.Tools;
import com.meichis.yndms.R;
import com.meichis.yndms.model.DSPToken;
import com.meichis.yndms.repository.manager.LoginRequestManager;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-05-08 15:26
 */
public class GestureLockVM extends MyAndroidViewModel {
    private MutableLiveData<String> userName  ;
    private MutableLiveData<String> passWord  ;
    private MutableLiveData<DSPToken> dspToken;
    private Context context;

    public GestureLockVM(@NonNull Application application) {
        super(application);
        context = application.getApplicationContext();
    }

    public MutableLiveData<String> getUserName() {
        if (userName == null){
            userName = new MutableLiveData<>();
        }
        return userName;
    }

    public MutableLiveData<String> getPassWord() {
        if (passWord ==null ){
            passWord = new MutableLiveData<>();
        }
        return passWord;
    }


    public MutableLiveData<DSPToken> getDspToken() {
        if (dspToken == null) {
            dspToken = new MutableLiveData<>();
        }
        return dspToken;
    }


    /**
     * 用户登陆接口
     */
    public void Login() {
        LoginRequestManager.getInstance().Login(getShowDialog(),
                String.valueOf(Tools.getPackageInfo(context).versionCode),
                context.getResources().getString(R.string.app_code),
                Tools.getNetType(context),
                getUserName().getValue(),
                getPassWord().getValue(),
                getDspToken());
    }

}
